package org.rulix.ogame.player.core;

import java.util.List;

import org.rulix.ogame.player.api.OgamePlanet;
import org.rulix.ogame.player.api.OgamePlanetCoordinates;

public class OgameSession {
	private String sessionId;
	private String ogameServer;
	private String login;
	private String password;
	private List<OgamePlanet> planets;
	
	public String getSessionId() {
		return sessionId;
	}
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	public String getOgameServer() {
		return ogameServer;
	}
	public void setOgameServer(String ogameServer) {
		this.ogameServer = ogameServer;
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public OgamePlanet findPlanet(OgamePlanetCoordinates coords) throws OgameException {
		for (OgamePlanet planet : planets) {
			if ( planet.getCoordinates().equals(coords) )
				return planet;
		}
		throw new OgameException("Could not find planet " + coords);
	}

	public OgamePlanet findPlanet(String cp) throws OgameException {
		for (OgamePlanet planet : planets) {
			if ( planet.getCode().equals(cp) )
				return planet;
		}
		throw new OgameException("Could not find planet " + cp);
	}

}
